package com.itheima.ydd.controller;

import com.itheima.ydd.common.Result;
import com.itheima.ydd.entity.SysConfig;
import com.itheima.ydd.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/sys_config")
public class SysConfigController {

    @Autowired
    private SysConfigService sysConfigService;

    /**
     * 添加配置
     *
     * @param sysConfig
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody SysConfig sysConfig) {

        System.out.println("sysConfig = " + sysConfig.toString());
        sysConfigService.save(sysConfig);
        return Result.ok("添加配置成功", null);
    }

    @GetMapping("/all")
    public  Result all(){

        Map<String,Object> map=sysConfigService.all();
        return Result.ok("",map);
    }
}
